package symbols;
import java.util.Iterator;
import java.util.LinkedHashSet;

public class HLSet extends LinkedHashSet {
	
	public Object clone() {
		HLSet newSet = new HLSet();
		HLSet oldSet = this;
		Iterator it = oldSet.iterator();
		
		while(it.hasNext()) {
			Object o = it.next();
			if(o instanceof Integer)
				newSet.add(new Integer(((Integer)o).intValue()));
			else if(o instanceof String)
				newSet.add(new String((String)o));
			else if(o instanceof HLSet)
				newSet.add(((HLSet)o).clone());
			else
				newSet.add(null);
		}
		
		return newSet;
	}
	
	/**
	 * Overriding toString to match HL syntax
	 */
	public String toString() {
		StringBuffer sb = new StringBuffer("{");
		Iterator it = this.iterator();
		if(it.hasNext())
			sb.append(it.next());
		while(it.hasNext())
			sb.append(", ").append(it.next());
		return sb.append("}").toString();
	}

	public boolean greatEqThan(HLSet val2) {
		return this.containsAll(val2);
	}

	public boolean greaterThan(HLSet val2) {
		return this.containsAll(val2) && this.size() > val2.size();
	}

	public boolean lessThan(HLSet val2) {
		return val2.containsAll(this) && val2.size() > this.size();
	}

	public boolean lessEqThan(HLSet val2) {
		return val2.containsAll(this);
	}
	
	// overriden from Object
	public boolean equals(HLSet val2) {
		return val2.containsAll(this) && this.containsAll(val2);
	}

	public boolean notComp(HLSet val2) {
		return this.size() != 0 && !this.containsAll(val2) && !val2.containsAll(this);
	}
	
}